import './index.scss';
import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
export default {
  data () {
    return {
      userId: '',
      isA: true,
      list: {
        day: '',
        month: '',
        number: '',
        totalMoney: '',
        userName: '',
        year: ''
      }
    }
  },
  mounted () {
    let openid = sessionStorage.getItem("openid")
    if (openid == null || openid == '' || openid == 'undefined') {
      sessionStorage.setItem('openid', this.$route.query.openId)
      sessionStorage.setItem('userId', this.$route.query.userId)
      sessionStorage.setItem('wxAvatar', this.$route.query.wxAvatar)
      sessionStorage.setItem('nickName', this.$route.query.nickName)
      let openid = sessionStorage.getItem("openid")
      if (openid == null || openid == '' || openid == 'undefined') {
        // alert('进行页面的跳转')
        window.location.href = 'http://www.qqchou.org/a/wxinterface/wxOAuth?category=4'
      }
    }
    if (this.$emit('ifOpenid')) {
      this.$emit('ifOpenid', this.$route.path)
    }
    if (this.$route.query.openId) {
      window.history.go(0)
    }
    this.userId = window.sessionStorage.getItem('userId')
    http.post(CONSTANT.DONATECERTIFICATE, {userId: this.userId}, (res) => {
      console.log(res)
      if (res.code == 200) {
        this.list = res.obj[0]
      }
    })
  },
  methods: {
    tabChange (e) {
      if (e == 'one') {
        this.isA = true
      } else {
        this.isA = false
      }
    },
    comeBack () {
      if (this.$route.query.userId) {
        this.$router.push({path: '/userhome'})
      } else {
        window.history.back()
      }
    }
  }
}
